/*
package com.hq.fxh.No0_ChengQu.Login;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.hq.fxh.HttpApi.UserServiceImpl;
import com.hq.fxh.Intefers.NetworkSubscriber;
import com.hq.fxh.Modle.SelectByMobileAndPwdRes;
import com.hq.fxh.No0_ChengQu.Activity.BaseActivity;
import com.hq.fxh.No0_ChengQu.Activity.HomeActivity;
import com.hq.fxh.No3_TuiGuang.MyMoBan.Activity.item.ToastUtils;
import com.hq.fxh.No3_TuiGuang.MyMoBan.ClearableEidtText;
import com.hq.fxh.R;
import com.hq.fxh.Utils.AppConstant;
import com.hq.fxh.Utils.CheckUtils;
import com.hq.fxh.Utils.IntentUtils;
import com.hq.fxh.Utils.LogUtils;
import com.hq.fxh.Utils.SharedPreferenceUtils;
import com.hq.fxh.Utils.Tool;

import cn.jiguang.analytics.android.api.JAnalyticsInterface;
import cn.jpush.im.android.api.JMessageClient;
import cn.jpush.im.android.api.model.UserInfo;
import cn.jpush.im.android.eventbus.EventBus;
import cn.jpush.im.api.BasicCallback;

import static com.hq.fxh.No0_ChengQu.Activity.AppUtils.getDeviceInfo;

*/
/**
 * @author 大圣
 * @ClassName LoginActivity
 * @Description :
 * @Created 16/5/17
 * @Email qwqe601660957@163.com
 *//*

public class LoginsActivity extends BaseActivity implements View.OnClickListener {
    protected TextView tvRegisterAgreement;
    protected LinearLayout layoutContent;
    protected ImageView toolbarImageBack;
    protected LinearLayout toolbarLayoutBack;
    protected TextView toolBarTvTitle;
    protected LinearLayout toolbarContent;
    protected ImageView imageLoginPhone;
    protected ImageView imageLoginPassword;
    */
/**
     * 账号输入框
     *//*

    private ClearableEidtText etAccount;
    */
/**
     * 密码输入框
     *//*

    private ClearableEidtText etPassword;
    */
/**
     * 登录按钮
     *//*

    private Button btnLogin;
    */
/**
     * 忘记密码
     *//*

    private TextView tvForgetPwd;
    */
/**
     * 注册账号
     *//*

    private TextView tvRegisterAccount;
     private String face;
    private String nickname;

    */
/**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     *//*


    @Override
    protected int getLayoutId() {
        return R.layout.login;
    }


    @Override
    protected void initView() {
         setSysColor(R.color.red, true);
        etAccount = (ClearableEidtText) findViewById(R.id.etAccount);
        etPassword = (ClearableEidtText) findViewById(R.id.etPassword);
        btnLogin = (Button) findViewById(R.id.btnLogin);
        btnLogin.setOnClickListener(this);
        tvForgetPwd = (TextView) findViewById(R.id.tvForgetPwd);
        tvForgetPwd.setOnClickListener(this);
        tvRegisterAccount = (TextView) findViewById(R.id.tvRegisterAccount);
        tvRegisterAccount.setOnClickListener(this);
        tvRegisterAgreement = (TextView) findViewById(R.id.tvRegisterAgreement);
        layoutContent = (LinearLayout) findViewById(R.id.layout_Content);
        toolbarImageBack = (ImageView) findViewById(R.id.toolbar_image_back);
        toolbarLayoutBack = (LinearLayout) findViewById(R.id.toolbar_Layout_back);
        toolbarLayoutBack.setOnClickListener(this);
        toolBarTvTitle = (TextView) findViewById(R.id.toolBar_tv_Title);
        toolbarContent = (LinearLayout) findViewById(R.id.toolbar_Content);
        imageLoginPhone = (ImageView) findViewById(R.id.image_login_phone);
        imageLoginPassword = (ImageView) findViewById(R.id.image_login_Password);
    }


    @Override
    public void onClick(View view) {
        LogUtils.e(" 点击事件");
        if (view.getId() == R.id.toolbar_Layout_back) {
            LogUtils.e(" 返回按钮");
            finish();
        } else if (view.getId() == R.id.btnLogin) {
            LogUtils.e(" 登录");
            login();
        } else if (view.getId() == R.id.tvRegisterAccount) {
            LogUtils.e(" 注册");
            toRegisterAccount();
        } else if (view.getId() == R.id.tvForgetPwd) {
            LogUtils.e(" 密码");
            toFindPswActivity();
        }
    }

    @Override
    protected void initData() {
        toolBarTvTitle.setText("用户登录");
        Tool.setEditorChange(etAccount, imageLoginPhone, R.mipmap.dl_shouji, R.mipmap.dl_shouji_to);
        Tool.setEditorChange(etPassword, imageLoginPassword, R.mipmap.dl_mima, R.mipmap.dl_mima_to);
    }


    @Override
    protected void onResume() {
        super.onResume();
        JAnalyticsInterface.onPageStart(this, "登录");
    }

    @Override
    protected void onPause() {
        super.onPause();
        JAnalyticsInterface.onPageEnd(this, "登录");
    }


    */
/**
     * 手机号登录
     *//*

//    private void loginByPhone() {
//        LoginReq req = checkInput();
//        if (req != null) {
//            loginByPhonePresenter.loginByPhone(req);
//        }
//    }

    */
/**
     * 输入检查
     *
     * @return
     *//*


    @Override
    protected void onDestroy() {
        super.onDestroy();
     }

    private void login() {
        final String account = CheckUtils.checkEditText(etAccount);
        if (TextUtils.isEmpty(account)) {
            LogUtils.startToash(this, R.string.input_account_not_empty);
            return;
        }
        final String pwd = CheckUtils.checkEditText(etPassword);
        if (TextUtils.isEmpty(pwd)) {
            LogUtils.startToash(this, R.string.input_pwd_not_empty);
            return;
        }
        */
/**
         * 根据手机号码和密码查询会员(登录)
         *//*

         String clientId = SharedPreferenceUtils.getClientId(LoginActivity.this);
        UserServiceImpl.selectByMobileAndPwd(account, pwd, getDeviceInfo(this), clientId, new NetworkSubscriber<SelectByMobileAndPwdRes>() {


            @Override
            public int onSuccess(SelectByMobileAndPwdRes data) {
                super.onSuccess(data);
                if (data != null && data.getCode() == 0) {
                    ToastUtils.show(LoginActivity.this, "登录成功");
                    loginIM();
                    toHome();

                    int memberId = data.getData().getUid();
                    int is_active = data.getData().getIs_active();
                    int level = data.getData().getLevel();
                    int isCompany = data.getData().getIs_company();
                    String expire_dt = data.getData().getExpire_dt();
                    String token = data.getData().getToken();
                    if (isCompany == 1) {
                        String company_name = data.getData().getCompany_name();
                        SharedPreferenceUtils.setCompanyName(LoginActivity.this, company_name);
                    }
                    saveMemberId(memberId, account, is_active, level, expire_dt, isCompany, token);
                    SharedPreferenceUtils.setPwd(LoginActivity.this, pwd);


                    nickname = data.getData().getNickname();

                    face = data.getData().getFace();


                } else {
                    String msg = data.getMsg();
                    if (msg == null) {
                        ToastUtils.show(LoginActivity.this, "登录失败");
                    } else {
                        ToastUtils.show(LoginActivity.this, msg);

                    }

                }


                return 0;
            }
        });
    }

    */
/**
     * 设置IM 信息
     *//*

    public void upIMMessage() {


        if (face == null) {
            LogUtils.startToash(this, " 用户IM昵称设置为空");
        } else {
            upDataIMPic(face);
        }
        if (nickname == null) {
            LogUtils.startToash(this, " 用户IM头像设置为空");
        } else {
            upDataIMName(nickname);
        }


    }


    public void toHome() {
        Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
        finish();

    }

    */
/**
     * 保存用户信息
     *//*

    public void saveMemberId(int memberId, String account, int is_active, int level, String expire_dt, int isCompany, String token) {
        SharedPreferences mySharedPreferences = getSharedPreferences("memberId", Activity.MODE_PRIVATE);
        SharedPreferences.Editor editor = mySharedPreferences.edit();
        editor.putInt("memberId", memberId);
        editor.putString("account", account);
        editor.putInt("is_active", is_active);
        editor.putInt("level", level);
        editor.putInt("isCompany", isCompany);
        editor.putString("expire_dt", expire_dt);
        editor.putString("token", token);
        editor.commit();


        //  startActivity(new Intent(LoginActivity.this, HomeActivity.class));


    }

    */
/**
     * 跳转到忘记密码页面
     *//*

    private void toFindPswActivity() {
        IntentUtils.openActivity(this, FindPwdActivity.class);
    }

    */
/**
     * 跳转到注册页面
     *//*

    private void toRegisterAccount() {
        IntentUtils.openActivity(this, RegisterActivity.class);
    }


    @Override
    protected void afterProgressDismiss() {

    }


    */
/**
     * 登录IM
     *//*

    public void loginIM() {
        final String account = CheckUtils.checkEditText(etAccount);
        if (TextUtils.isEmpty(account)) {
            ToastUtils.show(this, R.string.input_account_not_empty);
            return;
        }

        String pwd = CheckUtils.checkEditText(etPassword);
        if (TextUtils.isEmpty(pwd)) {
            ToastUtils.show(this, R.string.input_pwd_not_empty);
            return;
        }


        */
/**=================     调用SDk登陆接口    =================*//*

        JMessageClient.login(account, AppConstant.IMpassword, new BasicCallback() {
            @Override
            public void gotResult(int responseCode, String LoginDesc) {
                if (responseCode == 0) {
                    Log.i("登录IM成功", "JMessageClient.login" + ", responseCode = " + responseCode + " ; LoginDesc = " + LoginDesc);


                } else if (responseCode == 801003) {
                    register(account, AppConstant.IMpassword);
                } else {
                    LogUtils.startToash(LoginActivity.this, " 用户IM登录失败：" + responseCode);
                    Log.i("登录IM失败", "JMessageClient.login" + ", responseCode = " + responseCode + " ; LoginDesc = " + LoginDesc);

                }

            }
        });
    }

    */
/**
     * 注册后从新登录IM
     *//*

    public void loginIM(String account, String password) {

        */
/**=================     调用SDk登陆接口    =================*//*

        JMessageClient.login(account, password, new BasicCallback() {
            @Override
            public void gotResult(int responseCode, String LoginDesc) {
                if (responseCode == 0) {
                    Toast.makeText(LoginActivity.this, "登录IM成功", Toast.LENGTH_SHORT).show();
                    Log.i("登录IM成功", "JMessageClient.login" + ", responseCode = " + responseCode + " ; LoginDesc = " + LoginDesc);
                    upIMMessage();

                } else {
                    LogUtils.startToash(LoginActivity.this, " 用户IM登录失败：" + responseCode);

                    Log.i("登录IM失败", "JMessageClient.login" + ", responseCode = " + responseCode + " ; LoginDesc = " + LoginDesc);


                }

            }
        });
    }

    */
/**
     * 注册IM
     *//*

    public void register(final String account, final String password) {
        JMessageClient.register(account, password, new BasicCallback() {
            @Override
            public void gotResult(int responseCode, String registerDesc) {
                LogUtils.e(responseCode + "  IM   " + registerDesc);
                if (responseCode == 0) {
                    loginIM(account, password);
                } else {
                    LogUtils.startToash(LoginActivity.this, " 用户IM注册失败：" + responseCode);
                    Log.i("IMIIMIIMIIM", " .register" + ", responseCode = " + responseCode + " ; LoginDesc = " + registerDesc);

                }
            }
        });
    }


    */
/**
     * 更新用户IM头像信息
     *//*

    public void upDataIMPic(String url) {

        UserInfo myInfo = JMessageClient.getMyInfo();

        myInfo.setAddress(url);


        JMessageClient.updateMyInfo(UserInfo.Field.address, myInfo, new BasicCallback() {
            @Override
            public void gotResult(int i, String s) {
                if (i == 0) {

                    //     String picUrl = picList.get(currentPic).getPic_url();

                    Log.i("更新用户头像信息", "updateNickName," + " responseCode = " + i + "; desc = " + s);
                } else {

                    Log.i("更新用户头像信息", "updateNickName," + " responseCode = " + i + "; desc = " + s);
                }
            }
        });


    }

    */
/**
     * 更新用户IM昵称
     *//*

    public void upDataIMName(String nickName) {

        UserInfo myInfo = JMessageClient.getMyInfo();

        myInfo.setNickname(nickName);

        JMessageClient.updateMyInfo(UserInfo.Field.nickname, myInfo, new BasicCallback() {
            @Override
            public void gotResult(int i, String s) {
                if (i == 0) {
                    //     String picUrl = picList.get(currentPic).getPic_url();
                    Log.i("更新用户昵称信息", "updateNickName," + " responseCode = " + i + "; desc = " + s);
                } else {

                    Log.i("更新用户昵称信息", "updateNickName," + " responseCode = " + i + "; desc = " + s);
                }
            }
        });
    }

}
*/
